package main

import "fmt"

type Hero struct {
	No    int
	Name  string
	Left  *Hero
	Right *Hero
}

//前序遍历
func PreOrder(node *Hero) {
	if node != nil {
		fmt.Printf("no=%d name=%s\n", node.No, node.Name)
		PreOrder(node.Left)
		PreOrder(node.Right)
	}
}

//中序遍历
func infixOrder(node *Hero) {
	if node != nil {
		infixOrder(node.Left)
		fmt.Printf("no=%d name=%s\n", node.No, node.Name)
		infixOrder(node.Right)
	}
}

//后序遍历
func PostOrder(node *Hero) {
	if node != nil {
		PostOrder(node.Left)
		PostOrder(node.Right)
		fmt.Printf("no=%d name=%s\n", node.No, node.Name)
	}
}

func MyHero() {
	h1 := &Hero{
		No:   1,
		Name: "宋江l",
	}
	h2 := &Hero{
		No:   2,
		Name: "吴用l",
	}
	h3 := &Hero{
		No:   3,
		Name: "卢俊义r",
	}
	h4 := &Hero{
		No:   4,
		Name: "林冲r",
	}
	h5 := &Hero{
		No:   10,
		Name: "鲁智深l",
	}
	h6 := &Hero{
		No:   12,
		Name: "曹操r",
	}
	h1.Left = h2
	h1.Right = h3
	h3.Right = h4
	h2.Left = h5
	h2.Right = h6
	infixOrder(h1)
}
